package vistor

import (
	parser "antlr/grammar/gen"
	"fmt"
	"github.com/antlr4-go/antlr/v4"
)

type ComponentVisitor struct {
	parser.BaseMdlVisitor
}

func NewMdlVisitor() *ComponentVisitor {
	return &ComponentVisitor{}
}

func (v *ComponentVisitor) VisitMdlParser(ctx *parser.MdlParserContext) interface{} {
	if ctx.Create_component_stmt() != nil {
		return ctx.Create_component_stmt().Accept(v)
	}
	return nil
}

func (v *ComponentVisitor) VisitCreate_component_stmt(ctx *parser.Create_component_stmtContext) interface{} {
	for _, e := range ctx.AllAttribute_def() {
		e.Accept(v)
	}

	return v.VisitChildren(ctx)
}

func (v *ComponentVisitor) VisitComponent_type(ctx *parser.Component_typeContext) interface{} {
	return v.VisitChildren(ctx)
}

func (v *ComponentVisitor) VisitComponent_name(ctx *parser.Component_nameContext) interface{} {
	return v.VisitChildren(ctx)
}

func (v *ComponentVisitor) VisitAttribute_def(ctx *parser.Attribute_defContext) interface{} {
	fmt.Println("VisitSub_component_def")
	return v.VisitChildren(ctx)
}

func (v *ComponentVisitor) VisitSub_component_def(ctx *parser.Sub_component_defContext) interface{} {
	fmt.Println("VisitSub_component_def")
	return v.VisitChildren(ctx)
}

func (v *ComponentVisitor) Visit(tree antlr.ParseTree) interface{} {
	tree.Accept(v)
	return nil
}

func (v *ComponentVisitor) VisitChildren(node antlr.RuleNode) interface{} {
	return nil
}

func (v *ComponentVisitor) VisitTerminal(node antlr.TerminalNode) interface{} {
	return nil
}

func (v *ComponentVisitor) VisitErrorNode(node antlr.ErrorNode) interface{} {
	return nil
}
